package com.woniu.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.woniu.pojo.Roo;
import com.woniu.pojo.User;
import com.woniu.service.RooService;
import com.woniu.service.UserService;

@Controller
@RequestMapping("/user")
public class UserController {
	@Autowired
	private UserService userService;
	@Autowired
	private RooService rooService;
	@RequestMapping("/selectUserByHouseId")
	@ResponseBody
	public Map<String,Object> selectUserByHouseId(String house_id){
		Map<String,Object> map=new HashMap<>();
		List<User> userList = userService.selectUserByHouseId(house_id);
		map.put("userList", userList);
		Roo roo = rooService.selectRooByHouseId(house_id);
		if(roo==null) {
			map.put("roo", "");
		}else {
			map.put("roo", roo);
		}
		return map;
	}
	@RequestMapping("/updateUser")
	@ResponseBody
	public String updateUser(String u_id,String user_share,String h_years) {
		userService.updateUserShare(u_id, user_share, h_years);
		return "修改成功";
	}
}
